#!/usr/bin/perl -w
#the cut video file;
use DBI;
use mydb;
use File::Path;
use myvideo;
use server;
use myserver;
use Net::SCP::Expect;
use File::Basename qw<basename dirname>;
use createTask;
 

	my_connect();

#取任务控制表中的新建记录，按级别取值，并按建立时间排列， 为了保证系统的效率，每次返回10个记录
	$sql = "SELECT * FROM c_control WHERE status = 'new' order by level desc, ctime limit 10";

	$controlsth = $dbconn->prepare($sql) or die $dbconn->errstr;

	$controlsth->execute() or die "错误: " . $controlsth->errstr;

  	while (@data0 = $controlsth->fetchrow()) {

		
		$tid = $data0[0];	
		$total = $data0[2];
		if(createTask($tid, $total) != 1) {
		
			next;
		}
		
		$sql0 = "update c_control set running = total, btime = now(), status = 'transcode'  where tid = $tid";
		print "$sql0 \n";
		$sth0 = $dbconn->prepare($sql0) or die $dbconn->errstr;
		$sth0->execute() or die "错误: " . $sth0->errstr;

	}

#	my_disconnect();
